package cn.swufe.edu.stu.hw_tools.Cal;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import cn.swufe.edu.stu.hw_tools.R;

public class ZXActivity extends AppCompatActivity {
    private Button btn;
    private TextView v1,v2,v3,v4,v5,v6,v7;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zxactivity);
        btn = findViewById(R.id.CC4ZXback);
        v1 = findViewById(R.id.CC4ZX21);
        v2 = findViewById(R.id.CC4ZX22);
        v3 = findViewById(R.id.CC4ZX23);
        v4 = findViewById(R.id.CC4ZX24);
        v5 = findViewById(R.id.CC4ZX25);
        v6 = findViewById(R.id.CC4ZX26);
        v7 = findViewById(R.id.CC4ZX27);
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        v1.setText(String.format("%.2f",bundle.getFloat("out1",0.0f)));
        v2.setText(String.format("%.2f",bundle.getFloat("out2",0.0f)));
        v3.setText(String.format("%.2f",bundle.getFloat("out3",0.0f)));
        v4.setText(String.format("%.2f",bundle.getFloat("out4",0.0f)));
        v5.setText(String.format("%.2f",bundle.getFloat("out5",0.0f)));
        v6.setText(String.format("%.2f",bundle.getFloat("out6",0.0f)));
        v7.setText(String.format("%.2f",bundle.getFloat("out6",0.0f)));

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                float out1 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v1.getText().toString())));
                float out2 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v2.getText().toString())));
                float out3 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v3.getText().toString())));
                float out4 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v4.getText().toString())));
                float out5 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v5.getText().toString())));
                float out6 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v6.getText().toString())));
                float out7 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v7.getText().toString())));
                Intent intent = getIntent();
                Bundle bundle = new Bundle();
                bundle.putFloat("out1",out1);
                bundle.putFloat("out2",out2);
                bundle.putFloat("out3",out3);
                bundle.putFloat("out4",out4);
                bundle.putFloat("out5",out5);
                bundle.putFloat("out6",out6);
                bundle.putFloat("out7",out7);
                intent.putExtras(bundle);

                setResult(4,intent);
                finish();
            }
        });

    }
}